<template>
    <a-layout class="main">
        <div class="form">
            <a-button class="formButton" type="primary" @click="getProcessList">查询</a-button>
        </div>
        <a-layout-content>
            <a-table :loading="loading" rowKey="taskId" :columns="columns" :dataSource="dataSource">
                <span slot="operate" class="go" slot-scope="text,scope" @click="goPath(scope)">
                    处理
                </span>
            </a-table>
        </a-layout-content>
    </a-layout>
</template>

<script>
import { todoList, complete } from "../../components/process/api/todo"
export default {
    data() {
        return {
            dataSource: [],
            columns: [
                {
                    title: "任务编号",
                    dataIndex: "taskId",
                    key: "taskId"
                }, {
                    title: "流程名称",
                    dataIndex: "procDefName",
                    key: "procDefName"
                }, {
                    title: "任务节点",
                    dataIndex: "taskName",
                    key: "taskName"
                }, {
                    title: "流程版本",
                    dataIndex: "procDefVersion",
                    key: "procDefVersion",
                }, {
                    title: "流程发起人",
                    dataIndex: "startUserName",
                    key: "startUserName"
                }, {
                    title: "操作",
                    key: "operate",
                    scopedSlots: { customRender: 'operate' },
                }
            ],
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                name: null,
                category: null
            },
            loading: false,
        }
    },
    created() {
        this.getProcessList();
    },
    methods: {
        getProcessList() {
            this.loading = true
            todoList(this.queryParams).then(response => {
                console.log(response)
                if (response.code == 200) {
                    this.dataSource = response.data.records;
                } else {
                    this.$message.error(response.msg)
                }
            }).finally(() => {
                this.loading = false
            });
        },
        goPath(record) {
            this.$router.push({
                path: "/goProcess", query: {
                    procInsId: record.procInsId,
                    executionId: record.executionId,
                    deployId: record.deployId,
                    taskId: record.taskId,
                    finished: false
                }
            })
        }
    }
}
</script>

<style scoped lang="less">
.main {
    width: 1200px;
    margin: auto;
    margin-top: 20px;
    background-color: white;

    .form {
        display: flex;
        justify-content: center;

        .formButton {
            margin: 20px 0;
        }
    }

    .go {
        cursor: pointer;

        &:hover {
            color: #40a9ff;
        }
    }

}
</style>